#include "lolevel.h"
#include "platform.h"
#include "core.h"
#include "conf.h"

static long *nrflag = (long*)0x7910;

#include "../../../generic/capt_seq.c"

void __attribute__((naked,noinline)) hangdebug() {
	debug_led(1);
	while(1);
}

void __attribute__((naked,noinline)) blinko(void) {
	int i;
	//while(1) {
		*((volatile int *) 0xC02200B6) = 0x46; // Turn on LED
		for (i=0; i<0x200000; i++) { asm volatile ( "nop\n" ); }

		*((volatile int *) 0xC02200B6) = 0x44; // Turn off LED
		for (i=0; i<0x200000; i++) { asm volatile ( "nop\n" ); }

		*((volatile int *) 0xC02200B6) = 0x46; // Turn on LED
		for (i=0; i<0x200000; i++) { asm volatile ( "nop\n" ); }

		*((volatile int *) 0xC02200B6) = 0x44; // Turn off LED
		for (i=0; i<0x900000; i++) { asm volatile ( "nop\n" ); }
	//}
}

void __attribute__((naked,noinline)) capt_seq_task() {

 asm volatile (

"STMFD SP!, {R3-R9,LR}\n"
"LDR R6, =0x2D50\n"
"LDR R4, =0x3894C\n"
"MOV R9, #1\n"
"MOV R7, #0\n"

"loc_FF87CD54:\n"
	"LDR R0, [R6,#4]\n"
	"MOV R2, #0\n"
	"MOV R1, SP\n"
	"BL sub_FF838318\n"
	"TST R0, #1\n"
	"BEQ loc_FF87CD80\n"
	"LDR R1, =0x5B4\n"
	"LDR R0, =0xFF87C518\n"
	"BL sub_FF81E88C\n"
	"BL sub_FF81E844\n"
	"LDMFD SP!, {R3-R9,PC}\n"


"loc_FF87CD80:\n"
	"LDR R0, [SP]\n" // change here
	"LDR R1, [R0]\n"
	"CMP R1, #0x22\n"
	"ADDLS   PC, PC, R1,LSL#2\n" // change here
	"B loc_FF87D084\n"

"loc_FF87CD94: B  loc_FF87CE20\n"
"loc_FF87CD98: B  loc_FF87CE8C\n"
"loc_FF87CD9C: B  loc_FF87CEC8\n"
"loc_FF87CDA0: B  loc_FF87CEE8\n"
"loc_FF87CDA4: B  loc_FF87CEE0\n"
"loc_FF87CDA8: B  loc_FF87CEF0\n"
"loc_FF87CDAC: B  loc_FF87CEF8\n"
"loc_FF87CDB0: B  loc_FF87CF00\n"
"loc_FF87CDB4: B  loc_FF87CF58\n"
"loc_FF87CDB8: B  loc_FF87CF80\n"
"loc_FF87CDBC: B  loc_FF87CF64\n"
"loc_FF87CDC0: B  loc_FF87CF70\n"
"loc_FF87CDC4: B  loc_FF87CF78\n"
"loc_FF87CDC8: B  loc_FF87CF88\n"
"loc_FF87CDCC: B  loc_FF87CF90\n"
"loc_FF87CDD0: B  loc_FF87CF98\n"
"loc_FF87CDD4: B  loc_FF87CFA0\n"
"loc_FF87CDD8: B  loc_FF87CFA8\n"
"loc_FF87CDDC: B  loc_FF87CFB0\n"
"loc_FF87CDE0: B  loc_FF87CFB8\n"
"loc_FF87CDE4: B  loc_FF87CFC0\n"
"loc_FF87CDE8: B  loc_FF87CFC8\n"
"loc_FF87CDEC: B  loc_FF87CFD0\n"
"loc_FF87CDF0: B  loc_FF87CFDC\n"
"loc_FF87CDF4: B  loc_FF87CFE4\n"
"loc_FF87CDF8: B  loc_FF87CFF0\n"
"loc_FF87CDFC: B  loc_FF87CFF8\n"
"loc_FF87CE00: B  loc_FF87D028\n"
"loc_FF87CE04: B  loc_FF87D030\n"
"loc_FF87CE08: B  loc_FF87D038\n"
"loc_FF87CE0C: B  loc_FF87D040\n"
"loc_FF87CE10: B  loc_FF87D048\n"
"loc_FF87CE14: B  loc_FF87D050\n"
"loc_FF87CE18: B  loc_FF87D05C\n"
"loc_FF87CE1C: B  loc_FF87D090\n"

"loc_FF87CE20:\n"
	"BL sub_FF87D6A8\n"
					"BL      shooting_expo_param_override\n"  // +
	"BL sub_FF87A4E0\n"
 //  this code added to avoid some incorrect behavior if overrides are used.
 //  but it can cause some unexpected side effects. In this case, remove this code!
					"MOV     R0, #0\n"
					"STR     R0, [R4,#0x24]\n"  // fixes overrides  behavior at short shutter press
 //  end of my code
	"LDR R0, [R4,#0x24]\n"
	"CMP R0, #0\n"
	"BEQ loc_FF87D090\n"
	"BL sub_FF87C1F0\n"
	"MOV R5, R0\n"
	"LDR R0, [R4,#0x24]\n"
	"CMP R0, #0\n"
	"BEQ loc_FF87CE68\n"
	"MOV R0, #0xC\n"
	"BL sub_FF882154\n"
	"TST R0, #1\n"
	"STRNE R9, [R6,#0x10]\n"
	"LDRNE R0, [R5,#8]\n"
	"ORRNE R0, R0, #0x40000000\n" //
	"STRNE R0, [R5,#8]\n"
	"BNE loc_FF87D090\n"
"loc_FF87CE68:\n"
	"MOV R0, R5\n"
	"BL sub_FF961AC8\n"
	"MOV R0, R5\n"
	"BL sub_FF87C5D0\n"
	"MOV R0, R5\n"
					"BL sub_FF962364_my\n" // was sub_FF962364_my
					//"BL sub_FF962364\n" // was sub_FF962364_my
					"BL capt_seq_hook_raw_here\n"      // +
	"TST R0, #1\n"
	"STRNE R9, [R6,#0x10]\n"
	"B loc_FF87D090\n"
"loc_FF87CE8C:\n"
	"LDR R0, [R4,#0x24]\n"
	"CMP R0, #0\n"
	"BNE loc_FF87CEB8\n"
	"MOV R0, #0xC\n"
	"BL sub_FF882154\n"
	"TST R0, #1\n"
	"LDRNE	R0, [SP]\n"
	"MOVNE R1, #1\n"
	"LDRNE R2, [R0,#0xC]\n"
	"MOVNE R0, #1\n"
	"BNE loc_FF87CF50\n"
"loc_FF87CEB8:\n"
	"LDR	R0, [SP]\n"
//	"BL	sub_FF87C648\n"
					"BL	sub_FF87C648_my\n"
"loc_FF87CEC0:\n"
		"STR	R7, [R4,#0x24]\n"
		"B	loc_FF87D090\n"
"loc_FF87CEC8:\n"
		"MOV	R0, #1\n"
		"BL	sub_FF87D958\n"
		"LDR	R0, [R4,#0xC]\n"
		"CMP	R0, #0\n"
		"BLNE	sub_FF87E444\n"
		"B	loc_FF87D090\n"
"loc_FF87CEE0:\n"
		"BL	sub_FF87D358\n"
		"B	loc_FF87CEC0\n"
"loc_FF87CEE8:\n"
		"BL	sub_FF87D688\n"
		"B	loc_FF87CEC0\n"
"loc_FF87CEF0:\n"
		"BL	sub_FF87D690\n"
		"B	loc_FF87D090\n"
"loc_FF87CEF8:\n"
		"BL	sub_FF87D848\n"
		"B	loc_FF87CF5C\n"
"loc_FF87CF00:\n"
		"LDR	R5, [R0,#0xC]\n"
		"BL	sub_FF87D698\n"
		"MOV	R0, R5\n"
		"BL	sub_FF960B0C\n"
		"TST	R0, #1\n"
		"MOV	R8, R0\n"
		"BNE	loc_FF87CF40\n"
		"BL	sub_FF88F46C\n"
		"STR	R0, [R5,#0x18]\n"
		"MOV	R0, R5\n"
		"BL	sub_FF96227C\n"
		"MOV	R0, R5\n"
		"BL	sub_FF962674\n"
		"MOV	R8, R0\n"
		"LDR	R0, [R5,#0x18]\n"
		"BL	sub_FF88F670\n"
"loc_FF87CF40:\n"
		"BL	sub_FF87D688\n"
		"MOV	R2, R5\n"
		"MOV	R1, #9\n"
		"MOV	R0, R8\n"
"loc_FF87CF50:\n"
		"BL	sub_FF87AA74\n"
		"B	loc_FF87D090\n"
"loc_FF87CF58:\n"
		"BL	sub_FF87D8D8\n"
"loc_FF87CF5C:\n"
		"BL	sub_FF87A4E0\n"
		"B	loc_FF87D090\n"
"loc_FF87CF64:\n"
		"LDR	R0, [R4,#0x54]\n"
		"BL	sub_FF87DF5C\n"
		"B	loc_FF87D090\n"
"loc_FF87CF70:\n"
		"BL	sub_FF87E204\n"
		"B	loc_FF87D090\n"
"loc_FF87CF78:\n"
		"BL	sub_FF87E294\n"
		"B	loc_FF87D090\n"
"loc_FF87CF80:\n"
		"BL	sub_FF87D688\n"
		"B	loc_FF87D090\n"
"loc_FF87CF88:\n"
		"BL	sub_FF960D38\n"
		"B	loc_FF87D090\n"
"loc_FF87CF90:\n"
		"BL	sub_FF960F90\n"
		"B	loc_FF87D090\n"
"loc_FF87CF98:\n"
		"BL	sub_FF961030\n"
		"B	loc_FF87D090\n"
"loc_FF87CFA0:\n"
		"BL	sub_FF961164\n"
		"B	loc_FF87D090\n"
"loc_FF87CFA8:\n"
		"BL	sub_FF961234\n"
		"B	loc_FF87D090\n"
"loc_FF87CFB0:\n"
		"MOV	R0, #0\n"
		"B	loc_FF87CFD4\n"
"loc_FF87CFB8:\n"
		"BL	sub_FF96180C\n"
		"B	loc_FF87D090\n"
"loc_FF87CFC0:\n"
		"BL	sub_FF96189C\n"
		"B	loc_FF87D090\n"
"loc_FF87CFC8:\n"
		"BL	sub_FF96195C\n"
		"B	loc_FF87D090\n"
"loc_FF87CFD0:\n"
		"MOV	R0, #1\n"
"loc_FF87CFD4:\n"
		"BL	sub_FF9616CC\n"
		"B	loc_FF87D090\n"
"loc_FF87CFDC:\n"
		"BL	sub_FF87DB74\n"
		"B	loc_FF87D090\n"
"loc_FF87CFE4:\n"
		"BL	sub_FF87DC14\n"
		"BL	sub_FF87D1B8\n"
		"B	loc_FF87D090\n"
"loc_FF87CFF0:\n"
		"BL	sub_FF9614F4\n"
		"B	loc_FF87D090\n"
"loc_FF87CFF8:\n"
		"MOV	R2, #2\n"
		"ADD	R1, R4,	#0x6A\n"
		"MOV	R0, #0x6F\n"
		"BL	sub_FF88F2DC\n"
		"TST	R0, #1\n"
		"LDRNE	R1, =0x6AB\n"
		"LDRNE	R0, =0xFF87C518\n"
		"BLNE	sub_FF81E88C\n"
		"LDRH	R0, [R4,#0x6A]\n"
		"CMP	R0, #1\n"
		"BLEQ	sub_FF9614E8\n"
		"B	loc_FF87D090\n"
"loc_FF87D028:\n"
		"BL	sub_FF961620\n"
		"B	loc_FF87D090\n"
"loc_FF87D030:\n"
		"BL	sub_FF87C4A8\n"
		"B	loc_FF87D090\n"
"loc_FF87D038:\n"
		"BL	sub_FF835E64\n"
		"B	loc_FF87D090\n"
"loc_FF87D040:\n"
		"BL	sub_FF880584\n"
		"B	loc_FF87D090\n"
"loc_FF87D048:\n"
		"BL	sub_FF8805EC\n"
		"B	loc_FF87D090\n"
"loc_FF87D050:\n"
		"BL	sub_FF880648\n"
		"BL	sub_FF880608\n"
		"B	loc_FF87D090\n"
"loc_FF87D05C:\n"
		"MOV	R0, #1\n"
		"BL	sub_FF962EBC\n"
		"MOV	R0, #1\n"
		"BL	sub_FF962FCC\n"
		"LDRH	R0, [R4,#0xA8]\n"
		"CMP	R0, #4\n"
		"BNE	loc_FF87D090\n"
		"BL	sub_FF8805EC\n"
		"BL	sub_FF880A34\n"
		"B	loc_FF87D090\n"
"loc_FF87D084:\n"
		"LDR	R1, =0x709\n"
		"LDR	R0, =0xFF87C518\n"
		"BL	sub_FF81E88C\n"
"loc_FF87D090:\n"
		"LDR	R0, [SP]\n"
		"LDR	R1, [R0,#4]\n"
		"LDR	R0, [R6]\n"
		"BL	sub_FF88712C\n"
		"LDR	R5, [SP]\n"
		"LDR	R0, [R5,#8]\n"
		"CMP	R0, #0\n"
		"LDREQ	R1, =0x132\n"
		"LDREQ	R0, =0xFF87C518\n"
		"BLEQ	sub_FF81E88C\n"
		"STR	R7, [R5,#8]\n"
		"B	loc_FF87CD54\n"

// End of function capt_seq_task
 );
} 


// correct upto here


void __attribute__((naked,noinline)) sub_FF962364_my(){

 asm volatile(
		"STMFD	SP!, {R0-R8,LR}\n"
		"MOV	R4, R0\n"
		"BL	sub_FF9631B8\n"
		"LDR	R1, =0xFFFFFFFF\n"
		"BL	sub_FF887160\n"
		"LDR	R5, =0x7910\n"
		"LDR	R0, [R5,#0xC]\n"
		"CMP	R0, #0\n"
		"BNE	loc_FF9623B4\n"
		"MOV	R1, #1\n"
		"MOV	R0, #0\n"
		"BL	sub_FF838B60\n"
		"STR	R0, [R5,#0xC]\n"
		"MOV	R3, #0\n"
		"STR	R3, [SP]\n"  // STR     R3, [SP,#0x28+var_28]
		"LDR	R3, =0xFF961CF0\n"
		"LDR	R0, =0xFF9625DC\n" // prev LDR
		"MOV	R2, #0x400\n"
		"MOV	R1, #0x17\n"
		"BL	sub_FF838B2C\n"
"loc_FF9623B4:\n" //				; CODE XREF: _sub_FF962390__SsCaptureSeq.c__0+20j\n" get here
		"MOV	R2, #4\n"
		"ADD	R1, SP,	#8\n"
		"MOV	R0, #0x8A\n"
		"BL	sub_FF88F2DC\n"
		"TST	R0, #1\n"
		"LDRNE	R1, =0x3C5\n"
		"LDRNE	R0, =0xFF961F88\n"
		"BLNE	sub_FF81E88C\n"
		"LDR	R8, =0x38A20\n"
		"LDR	R7, =0x3894C\n"
		"LDRSH	R1, [R8,#0xE]\n"
		"LDR	R0, [R7,#0x9C]\n"
		"BL	sub_FF925240\n"
		"BL	sub_FF8626D0\n"
		"LDR	R3, =0x7918\n"
		"STRH	R0, [R4,#0xA4]\n"
		"SUB	R2, R3,	#4\n"
		"STRD	R2, [SP]\n" // this ok? STRD    R2, [SP,#0x28+var_28]
		"MOV	R1, R0\n"
		"LDRH	R0, [R7,#0x64]\n"
		"LDRSH	R2, [R8,#0xC]\n"
		"SUB	R3, R3,	#8\n"
		"BL	sub_FF96481C\n"
                 "BL      wait_until_remote_button_is_released\n"
                 "BL      capt_seq_hook_set_nr\n"                     // +
                 "B       sub_FF962410\n"                             // continue function in firmware
//		"LDR	R0, [R4,#0x1C]\n"
//		"CMP	R0, #0\n" // get here!
//		"MOVNE	R0, #1\n"
//		"STRNE	R0, [R5]\n"
//		"LDR	R0, [R5,#4]\n"
//		"BL	sub_FF9254CC\n"
//		"LDR	R0, [R5,#8]\n"
//		"BL	sub_FF8C83DC\n"
//		"MOV	R0, #1\n"
//		"BL	sub_FF8C83E8\n" // BX LR
//		"LDR	R0, =0xFF961D60\n"
//		"MOV	R1, R4\n"
//		"BL	sub_FF8C83B8\n"
//		"LDR	R0, [R5]\n"
//		"CMP	R0, #5\n" // get here!
//		"ADDLS	PC, PC,	R0,LSL#2\n" // badly wrong setting pc here
//                "BL     wait_until_remote_button_is_released\n"
//                "BL     capt_seq_hook_set_nr\n"                     // +
//		"B	sub_FF96251C\n"                             // continue function in firmware
 );

}





void __attribute__((naked,noinline)) sub_FF87C648_my(){
 asm volatile(
		"STMFD	SP!, {R3-R9,LR}\n"
		"LDR	R4, [R0,#0xC]\n"
		"LDR	R5, =0x3894C\n"
		"LDR	R0, [R4,#8]\n"
		"LDR	R6, =0x820A\n"
		"ORR	R0, R0,	#1\n"
		"STR	R0, [R4,#8]\n"
		"LDRH	R0, [R5]\n"
		"LDR	R8, =0x2D50\n"
		"MOV	R7, #0\n"
		"CMP	R0, R6\n"
		"BEQ	loc_FF87C6EC\n"
		"LDRH	R0, [R5,#0xA6]\n"
		"CMP	R0, #3\n"
		"BEQ	loc_FF87C74C\n" //
		"LDR	R0, [R4,#0xC]\n"
		"CMP	R0, #1\n"
		"BLS	loc_FF87C6F8\n"
		"LDRH	R0, [R5,#0xA4]\n"
		"CMP	R0, #0\n"
		"BNE	loc_FF87C74C\n"
		"LDRH	R0, [R5,#0xA0]\n"
		"CMP	R0, #2\n"
		"BNE	loc_FF87C704\n"
		"BL	sub_FF87DCC4\n"
		"LDRH	R0, [R5]\n"
		"CMP	R0, R6\n"
		"BEQ	loc_FF87C6EC\n"
		"LDRH	R0, [R5,#0xA6]\n"
		"CMP	R0, #3\n"
		"BEQ	loc_FF87C74C\n"
		"LDR	R0, [R4,#0xC]\n"
		"CMP	R0, #1\n"
		"BLS	loc_FF87C6F8\n"
		"LDRH	R0, [R5,#0xA4]\n"
		"CMP	R0, #0\n"
		"BNE	loc_FF87C74C\n"
		"LDRH	R0, [R5,#0xA0]\n"
		"CMP	R0, #2\n"
		"BEQ	loc_FF87C730\n"
		"B	loc_FF87C704\n"
"loc_FF87C6EC:\n" //				; CODE XREF: sub_FF87C648+2Cj\n"
		"LDRH	R0, [R5,#0xA6]\n"
		"CMP	R0, #3\n"
		"BEQ	loc_FF87C74C\n"
"loc_FF87C6F8:\n" //				; CODE XREF: sub_FF87C648+44j\n"
		"LDRH	R0, [R5,#0xA4]\n"
		"CMP	R0, #0\n"
		"BNE	loc_FF87C74C\n"
"loc_FF87C704:\n" //				; CODE XREF: sub_FF87C648+5Cj\n"
		"LDRH	R0, [R5,#0xA0]\n"
		"CMP	R0, #1\n"
		"BNE	loc_FF87C74C\n"
		"LDRH	R0, [R5]\n"
		"CMP	R0, R6\n"
		"LDRNE	R0, [R4,#0xC]\n"
		"CMPNE	R0, #1\n"
		"BLS	loc_FF87C74C\n"
		"LDR	R0, [R4,#0x10]\n"
		"CMP	R0, #1\n"
		"BNE	loc_FF87C74C\n"
"loc_FF87C730:\n" //				; CODE XREF: sub_FF87C648+9Cj\n"
		"LDR	R3, =0x269\n"
		"LDR	R2, =0xEA60\n"
		"STR	R3, [SP]\n"
		"LDR	R0, [R8]\n"
		"LDR	R3, =0xFF87C518\n" // copied from above ; "SsShootTask.c"\n" // adr
		"MOV	R1, #0x40000000\n"
		"BL	sub_FF8824D4\n"
"loc_FF87C74C:\n" //				; CODE XREF: sub_FF87C648+38j\n"
		"BL	sub_FF87C4A8\n"
		"LDR	R0, [R5,#0x24]\n"
		"CMP	R0, #0\n"
		"MOVEQ	R0, #2\n"
		"BLEQ	sub_FF876154\n"
		"BL	sub_FF87D698\n"
		"LDR	R0, [R5,#0x24]\n"
		"CMP	R0, #0\n"
		"BNE	loc_FF87C818\n"
		"MOV	R0, #0\n"
		"BL	sub_FF962EBC\n"
		"MOV	R0, #0\n"
		"BL	sub_FF962FCC\n"
		"MOV	R0, R4\n"
		"BL	sub_FF961AC8\n"
		"MOV	R0, R4\n"
		"BL	sub_FF87DAF0\n"
		"MOV	R0, R4\n"
		"BL	sub_FF9606C0\n"
		"CMP	R0, #0\n"
		"BEQ	loc_FF87C7CC\n" //changed
		"BL	sub_FF962EFC\n"
		"BL	sub_FF963010\n"
		"BL	sub_FF963060\n"
		"MOV	R0, R4\n"
		"BL	sub_FF960838\n"
		"TST	R0, #1\n"
		"MOVNE	R2, R4\n"
		"LDMNEFD	SP!, {R3-R9,LR}\n"
		"MOVNE	R1, #1\n"
		"BNE	sub_FF87AA74\n"
		"B	loc_FF87C7F4\n"
"loc_FF87C7CC:\n" //				; CODE XREF: sub_FF87C648+154j\n"
		"LDR	R0, [R5,#0xC]\n"
		"CMP	R0, #0\n"
		"BEQ	loc_FF87C7E0\n"
		"BL	sub_FF87E3C8\n"
		"BL	sub_FF877A24\n"
"loc_FF87C7E0:\n" //				; CODE XREF: sub_FF87C648+18Cj\n"
		"MOV	R0, R4\n"
		"BL	sub_FF9607A4\n"
		"BL	sub_FF962EFC\n" //changed
		"BL	sub_FF963010\n" // changed
		"BL	sub_FF963060\n" // changed
"loc_FF87C7F4:\n" //				; CODE XREF: sub_FF87C648+180j\n"
		"MOV	R0, R4\n"
		"BL	sub_FF87C5D0\n"
		"MOV	R0, R4\n"
		"BL	sub_FF96227C\n" //changed
		"BL	sub_FF962CF4\n" // changed
		"MOV	R0, R4\n"
					"BL	sub_FF962364_my\n"
		"MOV	R7, R0\n"
					"BL      capt_seq_hook_raw_here\n"      // +
		"B	loc_FF87C824\n"
"loc_FF87C818:\n" //				; CODE XREF: sub_FF87C648+124j\n"
		"LDR	R0, [R8,#0x10]\n"
		"CMP	R0, #0\n"
		"MOVNE	R7, #0x1D\n"
"loc_FF87C824:\n" //				; CODE XREF: sub_FF87C648+1CCj\n"
		"BL	sub_FF8805EC\n"
		"BL	sub_FF880634\n"
		"BL	sub_FF880674\n"
		"MOV	R2, R4\n"
		"MOV	R1, #1\n"
		"MOV	R0, R7\n"
		"BL	sub_FF87AA74\n"
		"BL	sub_FF962618\n" //changed
		"CMP	R0, #0\n"
		"LDRNE	R0, [R4,#8]\n"
		"ORRNE	R0, R0,	#0x2000\n"
		"STRNE	R0, [R4,#8]\n"
		"LDR	R0, [R4,#0x1C]\n"
		"CMP	R0, #0\n"
		"BLNE	sub_FF877A3C\n"
		"LDRH	R0, [R5,#0xA6]\n"
		"CMP	R0, #3\n"
		"BEQ	locret_FF87C888\n"
		"LDRH	R0, [R5,#0xA4]\n"
		"CMP	R0, #0\n"
		"LDREQH	R0, [R5,#0xA0]\n"
		"CMPEQ	R0, #2\n"
		"MOVEQ	R0, R4\n"
		"LDMEQFD	SP!, {R3-R9,LR}\n"
		"BEQ	sub_FF87DD18\n"
"locret_FF87C888:\n" //				; CODE XREF: sub_FF87C648+220j\n"
		"LDMFD	SP!, {R3-R9,PC}\n"

 );
}




/*************************************************************/
void __attribute__((naked,noinline)) exp_drv_task(){

//blinko();

 asm volatile(
		"STMFD	SP!, {R4-R8,LR}\n"
		"SUB	SP, SP,	#0x20\n"
		"LDR	R8, =0xBB8\n"
		"LDR	R7, =0x4658\n"
		"LDR	R5, =0x3D90C\n" // changed from 0x3D8EC
		"MOV	R0, #0\n"
		"ADD	R6, SP,	#0x10\n"
		"STR	R0, [SP,#0xC]\n"
"loc_FF8C1450:\n" //				; CODE XREF: task_ExpDrvTask+5B8j\n"
		"LDR	R0, [R7,#0x20]\n"
		"MOV	R2, #0\n"
		"ADD	R1, SP,	#0x1C\n"
		"BL	sub_FF838318\n"
		"LDR	R0, [SP,#0xC]\n"
		"CMP	R0, #1\n"
		"BNE	loc_FF8C149C\n"
		"LDR	R0, [SP,#0x1C]\n"
		"LDR	R0, [R0]\n"
		"CMP	R0, #0x13\n"
		"CMPNE	R0, #0x14\n"
		"CMPNE	R0, #0x15\n"
		"CMPNE	R0, #0x16\n"
		"BEQ	loc_FF8C15B8\n"
		"CMP	R0, #0x28\n"
		"BEQ	loc_FF8C1590\n"
		"ADD	R1, SP,	#0xC\n"
		"MOV	R0, #0\n"
		"BL	sub_FF8C13E0\n"
"loc_FF8C149C:\n" //				; CODE XREF: task_ExpDrvTask+38j\n"
		"LDR	R0, [SP,#0x1C]\n"
		"LDR	R1, [R0]\n"
		"CMP	R1, #0x2D\n"
		"BNE	loc_FF8C14CC\n"
		"LDR	R0, [SP,#0x1C]\n"
		"BL	sub_FF8C2698\n"
		"LDR	R0, [R7,#0x1C]\n"
		"MOV	R1, #1\n"
		"BL	sub_FF88712C\n"
		"BL	sub_FF81E844\n"
		"ADD	SP, SP,	#0x20\n"
		"LDMFD	SP!, {R4-R8,PC}\n"
"loc_FF8C14CC:\n" //				; CODE XREF: task_ExpDrvTask+78j\n"
		"CMP	R1, #0x2C\n"
		"BNE	loc_FF8C14E8\n"
		"LDR	R2, [R0,#0x8C]!\n"
		"LDR	R1, [R0,#4]\n"
		"MOV	R0, R1\n"
		"BLX	R2\n"
		"B	loc_FF8C19E0\n"
"loc_FF8C14E8:\n" //				; CODE XREF: task_ExpDrvTask+A0j\n"
		"CMP	R1, #0x26\n"
		"BNE	loc_FF8C1538\n"
		"LDR	R0, [R7,#0x1C]\n"
		"MOV	R1, #0x80\n"
		"BL	sub_FF887160\n"
		"LDR	R0, =0xFF8BDB6C\n"
		"MOV	R1, #0x80\n"
		"BL	sub_FF9516F0\n"
		"LDR	R0, [R7,#0x1C]\n"
		"MOV	R2, R8\n"
		"MOV	R1, #0x80\n"
		"BL	sub_FF88706C\n"
		"TST	R0, #1\n"
		"LDRNE	R1, =0xE54\n"
		"BNE	loc_FF8C157C\n"
"loc_FF8C1524:\n" //				; CODE XREF: task_ExpDrvTask+144j\n"
		"LDR	R1, [SP,#0x1C]\n"
		"LDR	R0, [R1,#0x90]\n"
		"LDR	R1, [R1,#0x8C]\n"
		"BLX	R1\n"
		"B	loc_FF8C19E0\n"
"loc_FF8C1538:\n" //				; CODE XREF: task_ExpDrvTask+BCj\n"
		"CMP	R1, #0x27\n"
		"BNE	loc_FF8C1588\n"
		"ADD	R1, SP,	#0xC\n"
		"BL	sub_FF8C13E0\n"
		"LDR	R0, [R7,#0x1C]\n"
		"MOV	R1, #0x100\n"
		"BL	sub_FF887160\n"
		"LDR	R0, =0xFF8BDB7C\n"
		"MOV	R1, #0x100\n"
		"BL	sub_FF95207C\n"
		"LDR	R0, [R7,#0x1C]\n"
		"MOV	R2, R8\n"
		"MOV	R1, #0x100\n"
		"BL	sub_FF88706C\n"
		"TST	R0, #1\n"
		"BEQ	loc_FF8C1524\n"
		"LDR	R1, =0xE5E\n"
"loc_FF8C157C:\n" //				; CODE XREF: task_ExpDrvTask+F0j\n"
		"LDR	R0, =0xFF8BE1E0\n"
		"BL	sub_FF81E88C\n"
		"B	loc_FF8C1524\n"
"loc_FF8C1588:\n" //				; CODE XREF: task_ExpDrvTask+10Cj\n"
		"CMP	R1, #0x28\n"
		"BNE	loc_FF8C15A0\n"
"loc_FF8C1590:\n" //				; CODE XREF: task_ExpDrvTask+5Cj\n"
		"LDR	R0, [SP,#0x1C]\n"
		"ADD	R1, SP,	#0xC\n"
		"BL	sub_FF8C13E0\n"
		"B	loc_FF8C1524\n"
"loc_FF8C15A0:\n" //				; CODE XREF: task_ExpDrvTask+15Cj\n"
		"CMP	R1, #0x2B\n"
		"BNE	loc_FF8C15B8\n"
		"BL	sub_FF8B17BC\n"
		"BL	sub_FF8B23E0\n"
		"BL	sub_FF8B1F34\n"
		"B	loc_FF8C1524\n"
"loc_FF8C15B8:\n" //				; CODE XREF: task_ExpDrvTask+54j\n"
		"LDR	R0, [SP,#0x1C]\n"
		"MOV	R4, #1\n"
		"LDR	R1, [R0]\n"
		"CMP	R1, #0x11\n"
		"CMPNE	R1, #0x12\n"
		"BNE	loc_FF8C1628\n"
		"LDR	R1, [R0,#0x7C]\n"
		"ADD	R1, R1,	R1,LSL#1\n"
		"ADD	R1, R0,	R1,LSL#2\n"
		"SUB	R1, R1,	#8\n"
		"LDMIA	R1, {R2-R4}\n"
		"STMIA	R6, {R2-R4}\n"
		"BL	sub_FF8BFD48\n" // loc -> sub
		"LDR	R0, [SP,#0x1C]\n"
		"LDR	R1, [R0,#0x7C]\n"
		"LDR	R3, [R0,#0x8C]\n"
		"LDR	R2, [R0,#0x90]\n"
		"ADD	R0, R0,	#4\n"
		"BLX	R3\n"
		"LDR	R0, [SP,#0x1C]\n"
		"BL	sub_FF8C2A5C\n"
		"LDR	R0, [SP,#0x1C]\n"
		"LDR	R1, [R0,#0x7C]\n"
		"LDR	R3, [R0,#0x94]\n"
		"LDR	R2, [R0,#0x98]\n"
		"ADD	R0, R0,	#4\n"
		"BLX	R3\n"
		"B	loc_FF8C1920\n"
"loc_FF8C1628:\n" //				; CODE XREF: task_ExpDrvTask+19Cj\n"
		"CMP	R1, #0x13\n"
		"CMPNE	R1, #0x14\n"
		"CMPNE	R1, #0x15\n"
		"CMPNE	R1, #0x16\n"
		"BNE	loc_FF8C16E0\n"
		"ADD	R3, SP,	#0xC\n"
		"MOV	R2, SP\n"
		"ADD	R1, SP,	#0x10\n"
		"BL	sub_FF8C0030\n"
		"CMP	R0, #1\n"
		"MOV	R4, R0\n"
		"CMPNE	R4, #5\n"
		"BNE	loc_FF8C167C\n"
		"LDR	R0, [SP,#0x1C]\n"
		"MOV	R2, R4\n"
		"LDR	R1, [R0,#0x7C]!\n"
		"LDR	R12, [R0,#0x10]!\n"
		"LDR	R3, [R0,#4]\n"
		"MOV	R0, SP\n"
		"BLX	R12\n"
		"B	loc_FF8C16B4\n"
"loc_FF8C167C:\n" //				; CODE XREF: task_ExpDrvTask+228j\n"
		"LDR	R0, [SP,#0x1C]\n"
		"CMP	R4, #2\n"
		"LDR	R3, [R0,#0x90]\n"
		"CMPNE	R4, #6\n"
		"BNE	loc_FF8C16C8\n"
		"LDR	R12, [R0,#0x8C]\n"
		"MOV	R0, SP\n"
		"MOV	R2, R4\n"
		"MOV	R1, #1\n"
		"BLX	R12\n"
		"LDR	R0, [SP,#0x1C]\n"
		"MOV	R2, SP\n"
		"ADD	R1, SP,	#0x10\n"
		"BL	sub_FF8C10E8\n"
"loc_FF8C16B4:\n" //				; CODE XREF: task_ExpDrvTask+248j\n"
		"LDR	R0, [SP,#0x1C]\n"
		"LDR	R2, [SP,#0xC]\n"
		"MOV	R1, R4\n"
		"BL	sub_FF8C1380\n"
		"B	loc_FF8C1920\n"
"loc_FF8C16C8:\n" //				; CODE XREF: task_ExpDrvTask+25Cj\n"
		"LDR	R1, [R0,#0x7C]\n"
		"LDR	R12, [R0,#0x8C]\n"
		"ADD	R0, R0,	#4\n"
		"MOV	R2, R4\n"
		"BLX	R12\n"
		"B	loc_FF8C1920\n"
"loc_FF8C16E0:\n" //				; CODE XREF: task_ExpDrvTask+208j\n"
		"CMP	R1, #0x22\n"
		"CMPNE	R1, #0x23\n"
		"BNE	loc_FF8C172C\n"
		"LDR	R1, [R0,#0x7C]\n"
		"ADD	R1, R1,	R1,LSL#1\n"
		"ADD	R1, R0,	R1,LSL#2\n"
		"SUB	R1, R1,	#8\n"
		"LDMIA	R1, {R2-R4}\n"
		"STMIA	R6, {R2-R4}\n"
		"BL	sub_FF8BF28C\n"
		"LDR	R0, [SP,#0x1C]\n"
		"LDR	R1, [R0,#0x7C]\n"
		"LDR	R3, [R0,#0x8C]\n"
		"LDR	R2, [R0,#0x90]\n"
		"ADD	R0, R0,	#4\n"
		"BLX	R3\n"
		"LDR	R0, [SP,#0x1C]\n"
		"BL	sub_FF8BF58C\n"
		"B	loc_FF8C1920\n"
"loc_FF8C172C:\n" //				; CODE XREF: task_ExpDrvTask+2B8j\n"
		"ADD	R1, R0,	#4\n"
		"LDMIA	R1, {R2,R3,R12}\n"
		"STMIA	R6, {R2,R3,R12}\n"
		"LDR	R1, [R0]\n"
		"CMP	R1, #0x25\n"
		"ADDLS	PC, PC,	R1,LSL#2\n"
		"B	loc_FF8C1900\n" 


"loc_FF8C1748:	B	loc_FF8C17E0\n"
"loc_FF8C174C:	B	loc_FF8C17E0\n"
"loc_FF8C1750:	B	loc_FF8C17E8\n"
"loc_FF8C1754:	B	loc_FF8C17F0\n"
"loc_FF8C1758:	B	loc_FF8C17F0\n"
"loc_FF8C175C:	B	loc_FF8C17F0\n"
"loc_FF8C1760:	B	loc_FF8C17E0\n"
"loc_FF8C1764:	B	loc_FF8C17E8\n"
"loc_FF8C1768:	B	loc_FF8C17F0\n"
"loc_FF8C176C:	B	loc_FF8C17F0\n"
"loc_FF8C1770:	B	loc_FF8C1808\n"
"loc_FF8C1774:	B	loc_FF8C1808\n"
"loc_FF8C1778:	B	loc_FF8C18F4\n"
"loc_FF8C177C:	B	loc_FF8C18FC\n"
"loc_FF8C1780:	B	loc_FF8C18FC\n"
"loc_FF8C1784:	B	loc_FF8C18FC\n"
"loc_FF8C1788:	B	loc_FF8C18FC\n"
"loc_FF8C178C:	B	loc_FF8C1900\n"


"loc_FF8C1790:	B	loc_FF8C1900\n"
"loc_FF8C1794:	B	loc_FF8C1900\n"
"loc_FF8C1798:	B	loc_FF8C1900\n"
"loc_FF8C179C:	B	loc_FF8C1900\n"
"loc_FF8C17A0:	B	loc_FF8C1900\n"
"loc_FF8C17A4:	B	loc_FF8C17F8\n"
"loc_FF8C17A8:	B	loc_FF8C1800\n"
"loc_FF8C17AC:	B	loc_FF8C1800\n"
"loc_FF8C17B0:	B	loc_FF8C1814\n"
"loc_FF8C17B4:	B	loc_FF8C1814\n"
"loc_FF8C17B8:	B	loc_FF8C181C\n"
"loc_FF8C17BC:	B	loc_FF8C181C\n"
"loc_FF8C17C0:	B	loc_FF8C187C\n"
"loc_FF8C17C4:	B	loc_FF8C18AC\n"
"loc_FF8C17C8:	B	loc_FF8C18DC\n"
"loc_FF8C17CC:	B	loc_FF8C18DC\n"
"loc_FF8C17D0:	B	loc_FF8C1900\n"
"loc_FF8C17D4:	B	loc_FF8C1900\n"
"loc_FF8C17D8:	B	loc_FF8C18E4\n"
"loc_FF8C17DC:	B	loc_FF8C18EC\n"

"loc_FF8C17E0:\n" //				; CODE XREF: task_ExpDrvTask+310j\n"
		"BL	sub_FF8BE084\n"
		"B	loc_FF8C1900\n"
"loc_FF8C17E8:\n" //				; CODE XREF: task_ExpDrvTask+310j\n"
		"BL	sub_FF8BE30C\n"
		"B	loc_FF8C1900\n"
"loc_FF8C17F0:\n" //				; CODE XREF: task_ExpDrvTask+310j\n"
		"BL	sub_FF8BE514\n"
		"B	loc_FF8C1900\n"
"loc_FF8C17F8:\n" //				; CODE XREF: task_ExpDrvTask+310j\n"
		"BL	sub_FF8BE78C\n"
		"B	loc_FF8C1900\n"
"loc_FF8C1800:\n" //				; CODE XREF: task_ExpDrvTask+310j\n"
		"BL	sub_FF8BE984\n"
		"B	loc_FF8C1900\n"
"loc_FF8C1808:\n" //				; CODE XREF: task_ExpDrvTask+310j\n"
//		"BL	sub_FF8BEC50\n"
		"BL	sub_FF8BEC40_my\n" // ---->
		"MOV	R4, #0\n"
		"B	loc_FF8C1900\n"
"loc_FF8C1814:\n" //				; CODE XREF: task_ExpDrvTask+310j\n"
		"BL	sub_FF8BED80\n"
		"B	loc_FF8C1900\n"
"loc_FF8C181C:\n" //				; CODE XREF: task_ExpDrvTask+310j\n"
		"LDRH	R1, [R0,#4]\n"
		"STRH	R1, [SP,#0x10]\n"
		"LDRH	R1, [R5,#2]\n"
		"STRH	R1, [SP,#0x12]\n"
		"LDRH	R1, [R5,#4]\n"
		"STRH	R1, [SP,#0x14]\n"
		"LDRH	R1, [R5,#6]\n"
		"STRH	R1, [SP,#0x16]\n"
		"LDRH	R1, [R0,#0xC]\n"
		"STRH	R1, [SP,#0x18]\n"
		"BL	sub_FF8C270C\n"
		"B	loc_FF8C1900\n"
"loc_FF8C184C:\n" //				; CODE XREF: task_ExpDrvTask+310j\n"
		"LDRH	R1, [R0,#4]\n"
		"STRH	R1, [SP,#0x10]\n"
		"LDRH	R1, [R5,#2]\n"
		"STRH	R1, [SP,#0x12]\n"
		"LDRH	R1, [R5,#4]\n"
		"STRH	R1, [SP,#0x14]\n"
		"LDRH	R1, [R5,#6]\n"
		"STRH	R1, [SP,#0x16]\n"
		"LDRH	R1, [R5,#8]\n"
		"STRH	R1, [SP,#0x18]\n"
		"BL	sub_FF8C2874\n"
		"B	loc_FF8C1900\n"
"loc_FF8C187C:\n" //				; CODE XREF: task_ExpDrvTask+310j\n"
		"LDRH	R1, [R5]\n"
		"STRH	R1, [SP,#0x10]\n"
		"LDRH	R1, [R0,#6]\n"
		"STRH	R1, [SP,#0x12]\n"
		"LDRH	R1, [R5,#4]\n"
		"STRH	R1, [SP,#0x14]\n"
		"LDRH	R1, [R5,#6]\n"
		"STRH	R1, [SP,#0x16]\n"
		"LDRH	R1, [R5,#8]\n"
		"STRH	R1, [SP,#0x18]\n"
		"BL	sub_FF8C2920\n"
		"B	loc_FF8C1900\n"
"loc_FF8C18AC:\n" //				; CODE XREF: task_ExpDrvTask+310j\n"
		"LDRH	R1, [R5]\n"
		"STRH	R1, [SP,#0x10]\n"
		"LDRH	R1, [R5,#2]\n"
		"STRH	R1, [SP,#0x12]\n"
		"LDRH	R1, [R5,#4]\n"
		"STRH	R1, [SP,#0x14]\n"
		"LDRH	R1, [R5,#6]\n"
		"STRH	R1, [SP,#0x16]\n"
		"LDRH	R1, [R0,#0xC]\n"
		"STRH	R1, [SP,#0x18]\n"
		"BL	sub_FF8C29C0\n"
		"B	loc_FF8C1900\n"
"loc_FF8C18DC:\n" //				; CODE XREF: task_ExpDrvTask+310j\n"
		"BL	sub_FF8BF0C8\n"
		"B	loc_FF8C1900\n"
"loc_FF8C18E4:\n" //				; CODE XREF: task_ExpDrvTask+310j\n"
		"BL	sub_FF8BF690\n"
		"B	loc_FF8C1900\n"
"loc_FF8C18EC:\n" //				; CODE XREF: task_ExpDrvTask+310j\n"
		"BL	sub_FF8BF8CC\n"
		"B	loc_FF8C1900\n"
"loc_FF8C18F4:\n" //				; CODE XREF: task_ExpDrvTask+310j\n"
		"BL	sub_FF8BFA48\n"
		"B	loc_FF8C1900\n"
"loc_FF8C18FC:\n" //				; CODE XREF: task_ExpDrvTask+310j\n"
		"BL	sub_FF8BFBE4\n"
"loc_FF8C1900:\n" //				; CODE XREF: task_ExpDrvTask+310j\n"
		"LDR	R0, [SP,#0x1C]\n"
		"LDR	R1, [R0,#0x7C]\n"
		"LDR	R3, [R0,#0x8C]\n"
		"LDR	R2, [R0,#0x90]\n"
		"ADD	R0, R0,	#4\n"
		"BLX	R3\n"
		"CMP	R4, #1\n"
		"BNE	loc_FF8C1968\n"
"loc_FF8C1920:\n" //				; CODE XREF: task_ExpDrvTask+1F4j\n"
		"LDR	R0, [SP,#0x1C]\n"
		"MOV	R2, #0xC\n"
		"LDR	R1, [R0,#0x7C]\n"
		"ADD	R1, R1,	R1,LSL#1\n"
		"ADD	R0, R0,	R1,LSL#2\n"
		"SUB	R4, R0,	#8\n"
		"LDR	R0, =0x3D90C\n" // changed from 3D8EC
		"ADD	R1, SP,	#0x10\n"
		"BL	sub_FFB366B4\n"
		"LDR	R0, =0x3D918\n" // changed from 3D8F8
		"MOV	R2, #0xC\n"
		"ADD	R1, SP,	#0x10\n"
		"BL	sub_FFB366B4\n"
		"LDR	R0, =0x3D924\n" // changed from 3D904
		"MOV	R2, #0xC\n"
		"MOV	R1, R4\n"
		"BL	sub_FFB366B4\n"
		"B	loc_FF8C19E0\n"
"loc_FF8C1968:\n" //				; CODE XREF: task_ExpDrvTask+4ECj\n"
		"LDR	R0, [SP,#0x1C]\n"
		"LDR	R0, [R0]\n"
		"CMP	R0, #0xB\n"
		"BNE	loc_FF8C19B0\n"
		"MOV	R3, #0\n"
		"STR	R3, [SP]\n"
		"MOV	R3, #1\n"
		"MOV	R2, #1\n"
		"MOV	R1, #1\n"
		"MOV	R0, #0\n"
		"BL	sub_FF8BDE8C\n"
		"MOV	R3, #0\n"
		"STR	R3, [SP]\n"
		"MOV	R3, #1\n"
		"MOV	R2, #1\n"
		"MOV	R1, #1\n"
		"MOV	R0, #0\n"
		"B	loc_FF8C19CC\n"
"loc_FF8C19B0:\n" //				; CODE XREF: task_ExpDrvTask+544j\n"
		"MOV	R3, #1\n"
		"MOV	R2, #1\n"
		"MOV	R1, #1\n"
		"MOV	R0, #1\n"
		"STR	R3, [SP]\n"
		"BL	sub_FF8BDE8C\n"
		"MOV	R3, #1\n"
		"MOV	R2, #1\n"
		"MOV	R1, #1\n"
		"MOV	R0, #1\n"
		"STR	R3, [SP]\n"
"loc_FF8C19CC:\n" //				; CODE XREF: task_ExpDrvTask+57Cj\n"
		"BL	sub_FF8BDFCC\n"
"loc_FF8C19E0:\n" //				; CODE XREF: task_ExpDrvTask+B4j\n"
		"LDR	R0, [SP,#0x1C]\n"
		"BL	sub_FF8C2698\n"
		"B	loc_FF8C1450\n"
//; End of function task_ExpDrvTask\n"

 );
}


void __attribute__((naked,noinline)) sub_FF8BEC40_my(){

 asm volatile(
		"STMFD	SP!, {R4-R8,LR}\n"
		"LDR	R7, =0x4658\n"
		"MOV	R4, R0\n"
		"LDR	R0, [R7,#0x1C]\n"
		"MOV	R1, #0x3E\n"
		"BL	sub_FF887160\n"
		"LDRSH	R0, [R4,#4]\n"
		"MOV	R2, #0\n"
		"MOV	R1, #0\n"
		"BL	sub_FF8BDBF0\n"
		"MOV	R6, R0\n"
		"LDRSH	R0, [R4,#6]\n"
		"BL	sub_FF8BDD00\n"
		"LDRSH	R0, [R4,#8]\n"
		"BL	sub_FF8BDD58\n"
		"LDRSH	R0, [R4,#0xA]\n"
		"BL	sub_FF8BDDB0\n"
		"LDRSH	R0, [R4,#0xC]\n"
		"MOV	R1, #0\n"
		"BL	sub_FF8BDE08\n"
		"MOV	R5, R0\n"
		"LDR	R0, [R4]\n"
		"LDR	R8, =0x3D924\n" // changed from 3D904
		"CMP	R0, #0xB\n"
		"MOVEQ	R6, #0\n"
		"MOVEQ	R5, #0\n"
		"BEQ	loc_FF8BECD4\n"
		"CMP	R6, #1\n"
		"BNE	loc_FF8BECD4\n"
		"LDRSH	R0, [R4,#4]\n"
		"LDR	R1, =0xFF8BDB5C\n"
		"MOV	R2, #2\n"
		"BL	sub_FF951A38\n"
		"STRH	R0, [R4,#4]\n"
		"MOV	R0, #0\n"
		"STR	R0, [R7,#0x28]\n"
		"B	loc_FF8BECDC\n" 

"loc_FF8BECD4:\n" //				; CODE XREF: _sub_FF8BEC50__ExpDrv.c__2+68j\n"
		"LDRH	R0, [R8]\n"
		"STRH	R0, [R4,#4]\n"
"loc_FF8BECDC:\n" //				; CODE XREF: _sub_FF8BEC50__ExpDrv.c__2+90j\n"
		"CMP	R5, #1\n"
		"LDRNEH	R0, [R8,#8]\n"
		"BNE	loc_FF8BECF8\n"
		"LDRSH	R0, [R4,#0xC]\n"
		"LDR	R1, =0xFF8BDBE0\n"
		"MOV	R2, #0x20\n"
		"BL	sub_FF8C26C8\n"
"loc_FF8BECF8:\n" //				; CODE XREF: _sub_FF8BEC50__ExpDrv.c__2+A4j\n"
		"STRH	R0, [R4,#0xC]\n"
		"LDRSH	R0, [R4,#6]\n"
//		"BL	sub_FF8B153C\n"
		"BL	sub_FF8B152C_my\n"
		"LDRSH	R0, [R4,#8]\n"
		"MOV	R1, #1\n"
		"BL	sub_FF8B1C7C\n"
		"MOV	R1, #0\n"
		"ADD	R0, R4,	#8\n"
		"BL	sub_FF8B1D04\n"
		"LDRSH	R0, [R4,#0xE]\n"
		"BL	sub_FF8B96A8\n"
		"LDR	R4, =0xBB8\n"
		"CMP	R6, #1\n"
		"BNE	loc_FF8BED50\n"
		"LDR	R0, [R7,#0x1C]\n"
		"MOV	R2, R4\n"
		"MOV	R1, #2\n"
		"BL	sub_FF88706C\n"
		"TST	R0, #1\n"
		"SUBNE	R1, R4,	#0x620\n"
		"LDRNE	R0, =0xFF8BE1E0\n"
		"BLNE	sub_FF81E88C\n"
"loc_FF8BED50:\n" //				; CODE XREF: _sub_FF8BEC50__ExpDrv.c__2+ECj\n"
		"CMP	R5, #1\n"
		"LDMNEFD	SP!, {R4-R8,PC}\n"
		"LDR	R0, [R7,#0x1C]\n"
		"MOV	R2, R4\n"
		"MOV	R1, #0x20\n"
		"BL	sub_FF88706C\n"
		"TST	R0, #1\n"
		"LDRNE	R1, =0x59D\n"
		"LDRNE	R0, =0xFF8BE1E0\n"
		"LDMNEFD	SP!, {R4-R8,LR}\n"
		"BNE	sub_FF81E88C\n"
		"LDMFD	SP!, {R4-R8,PC}\n"
//; End of function _sub_FF8BEC50__ExpDrv.c__2\n" 
 );
}

void __attribute__((naked,noinline)) sub_FF8B152C_my(){

 asm volatile(
		"STMFD	SP!, {R4-R6,LR}\n"
		"LDR	R5, =0x4370\n"
		"MOV	R4, R0\n"
		"LDR	R0, [R5,#4]\n"
		"CMP	R0, #1\n"
		"LDRNE	R1, =0x146\n"
		"LDRNE	R0, =0xFF8B1330\n"
		"BLNE	sub_FF81E88C\n"
		"CMN	R4, #0xC00\n"
		"LDREQSH	R4, [R5,#2]\n"
		"CMN	R4, #0xC00\n"
		"MOVEQ	R1, #0x14C\n"
		"LDREQ	R0, =0xFF8B1330\n"
		"STRH	R4, [R5,#2]\n"
		"BLEQ	sub_FF81E88C\n"
		"MOV	R0, R4\n"
//		"BL	sub_FFA080B8\n"
		"BL	apex2us\n"
		"MOV	R4, R0\n"
//		"BL	nullsub_59\n"
		"MOV	R0, R4\n"
		"BL	sub_FF8F3308\n"
		"TST	R0, #1\n"
		"LDRNE	R1, =0x151\n"
		"LDMNEFD	SP!, {R4-R6,LR}\n"
		"LDRNE	R0, =0xFF8B1330\n"
		"BNE	sub_FF81E88C\n"
		"LDMFD	SP!, {R4-R6,PC}\n" 
// End of function sub_FF89D14C
 );
}
